package com.bw.dao;

import com.bw.bean.Sugar1;
import com.bw.bean.Sugar2;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SugarDao {
    @Select("call spOne()")
    List<Sugar1> getList1();

    @Select("select d.name,count(o.id) `value` from order_info o \n" +
            "LEFT JOIN order_cargo c ON c.order_id=o.id \n" +
            "LEFT JOIN base_dic d ON c.cargo_type=d.id\n" +
            "GROUP BY d.name")
    List<Sugar1> getList2();

    @Select("select org_name name,\n" +
            "sum(actual_distance) distance,\n" +
            "count(o.org_name) num,\n" +
            "sum(TIMESTAMPDIFF(SECOND,actual_start_time,actual_end_time))`time`,\n" +
            "sum(actual_distance)/count(o.org_name) avgDistance,\n" +
            "sum(TIMESTAMPDIFF(SECOND,actual_start_time,actual_end_time))/count(o.org_name) avgName\n" +
            "from transport_task t \n" +
            "LEFT JOIN line_base_info b ON t.line_id=b.id \n" +
            "LEFT JOIN base_organ o ON b.org_id=o.id\n" +
            "GROUP BY o.org_name ")
    List<Sugar2> getList3();
}
